﻿using System.Text.Json;
using System.Text.Json.Serialization;

namespace Grow.Json.Text.Parse
{
    public class FloatParse : JsonConverter<float>
    {
        public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            bool flag = reader.TryGetSingle(out float value);
            return flag == true ? value : default;
        }

        public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
        {
            writer.WriteNumberValue(value);
        }
    }
}
